/*
 * @Description:
 * @Version: 2.0
 * @Autor: wiz
 * @Date: 2024-02-14 17:43:00
 * @LastEditors: wiz
 * @LastEditTime: 2024-02-14 18:18:52
 */
import { Tsrv, ifs } from '@/services';
import { N_oBaseForm } from './types';

class T_cmd {
  // 主组件箱
  private compBox: ifs.I_compBox;

  // 主组件ID
  private compID: string;

  // 主组件实例
  private oBaseForm: N_oBaseForm.oBaseForm;
  // 主组refs

  constructor(self: any, compBoxInfo: ifs.I_compBoxInfo) {
    this.oBaseForm = self;
    this.compBox = compBoxInfo.TcompBox;
    this.compID = compBoxInfo.compID;
  }

  // 主组件created里初始化
  public init(self: N_oBaseForm.oBaseForm, compBoxInfo: ifs.I_compBoxInfo) {
    // this.oBaseForm = self;
    // this.compBox = compBoxInfo.TcompBox;
    // this.compID = compBoxInfo.compID;
  }

  public getTcmd(): T_cmd {
    return this;
  }

  // 获取活跃数据（即选中的数据--表头id，表体选中的id）
  public getSelectedData() {
    const params = {
      funName: this.oBaseForm.funName,
      title: '',
      from: '',
      data: {
        rows: {}
      }
    };
    params.data[this.oBaseForm.funName] = [this.oBaseForm.formID];
    params.data.rows[this.oBaseForm.funName] = [
      Tsrv.utils.clone(this.oBaseForm.localData, true)
    ];

    // params.data['custBtns'] = [];
    // this.oBaseForm.toolbar['addon'].forEach(el => {
    //   params.data['custBtns'].push({ title: el.title, status: el.auth });
    // });
    return params;
  }
}
interface I_cmd extends T_cmd {}
export { I_cmd, T_cmd };
